package zy;
/*
 *@Student 张策
 */
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Warehouse {
    public List<Dish> dishes = new ArrayList<>();
    public Warehouse(){
        this.dishes.add(new Dish(this.dishes.size()+1,"宫保鸡丁",9.0,"不辣还好吃",0));
        this.dishes.add(new Dish(this.dishes.size()+1,"彪哥小面",8.0,"加豆干好吃",0));
        this.dishes.add(new Dish(this.dishes.size()+1,"杂粮煎饼",7.0,"加肉松好吃",0));
    }
    //展示菜单
    public Dish getDish(int pos){
        return this.dishes.get(pos-1);
    }
    //增加库存
    public void addDish(Dish dish) {
        dishes.add(dish);
    }
    public void cookDish(int id) {
        for (Dish dish : dishes) {
            if (dish.id == id) {
                dish.stock++;
                System.out.println("库存增加成功！");
                return;
            }
        }
        System.out.println("菜品不存在！");
    }

    public void throwDish(int id) {
        for (Dish dish : dishes) {
            if (dish.id == id) {
                if (dish.stock > 0) {
                    dish.stock--;
                    System.out.println("库存减少成功！");
                } else {
                    System.out.println("库存不足！");
                }
                return;
            }
        }
        System.out.println("菜品不存在！");
    }
}

